package com.cindata

import com.cindata.dictionary.*

class MortgageCollectionRecord
{
    // 催收类型
    MortgageCollectionType collectionType
    // 催收措施
    String collectionMethod
    // 催收部门
    String department
    // 催收人员
    String fullName
    // 客户约定还款计划
    String repaymentPlan
    // 逾期还款后果提示
    Boolean isRemindedConsequence = true
    // 逾期原因
    String reasonOfOverdue
    // 催收结果
    String collectionResult
    //委外机构
    Account agencyAccount

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User user
    User createBy
    User modifyBy

    static belongsTo = [mortgage: Mortgage, abnormalMortgageBatch: AbnormalMortgageBatch]

    static constraints = {

        mortgage nullable: true, blank: true
        abnormalMortgageBatch nullable: true, blank: true

        collectionMethod nullable: true, blank: true
        department nullable: true, blank: true
        fullName nullable: true, blank: true
        repaymentPlan nullable: true, blank: true
        isRemindedConsequence nullable: true, blank: true
        reasonOfOverdue nullable: true, blank: true
        collectionResult nullable: true, blank: true
        agencyAccount nullable: true, blank: true

        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        user nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true
    }

    def springSecurityService

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }

    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }
}
